package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.common.aspect.AutoFill;
import com.sky.common.aspect.OperationType;
import com.sky.pojo.entity.Employee;
import org.apache.ibatis.annotations.*;

@Mapper
public interface EmployeeMapper {

    @Select("select * from employee where id = #{id}")
    Employee getById(Long id);

    @Select("select * from employee where username = #{username}")
    Employee getByName(String username);

    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);


    @Insert("insert into employee values (null, #{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Employee employee);


    @Delete("DELETE FROM employee WHERE id = #{id}")
    Boolean deleteEmpById(Long id);


    @Delete("DELETE FROM employee WHERE username = #{username}")
    Boolean deleteEmpByUserName(String username);


    Page<Employee> list(String name);

    @AutoFill(OperationType.UPDATE)
    Boolean update(Employee employee);
}
